#pragma once

#include "imimp4_ffmpeg.h"
#include "imierrorcode.h"
#include <string.h>
#include <stdio.h>
#include <list>
#include "imiapihandlemap.h"

using namespace std;

namespace imimp4_namespace
{
	class imimp4ffmpeg_impl
	{
	public:
		imimp4ffmpeg_impl();
		~imimp4ffmpeg_impl();
	public:
		int create(const char* path,
				   container_format_id container,
				   video_codec_id video,
				   audio_codec_id audio,
				   unsigned int vfps,
				   unsigned int vwidth,
				   unsigned int vheight,
				   unsigned int achannel,
				   unsigned int asamplerate);
		int write_video(unsigned char* data,
						unsigned int data_len,
						unsigned int vtimestamp,
						bool iskeyframe);
		int write_audio(unsigned char* data,
						unsigned int data_len,
						unsigned int atimestamp);
		int close_create();

		int open(const char* path,
				 container_format_id* container,
				 video_codec_id* video,
				 audio_codec_id* audio,
				 unsigned int* vfps,
				 unsigned int* vwidth,
				 unsigned int* vheight,
				 unsigned int* achannel,
				 unsigned int* asamplerate,
				 unsigned int* abitrate);

		int get_frame(unsigned char* data,
					  unsigned int* data_len,
					  unsigned int* timestamp,
					  bool* iskeyframe,
					  bool* isaudioframe);

		int close_open();

	private:
		void* _mp4_handle;
	};
}
